package lesson08;

import java.util.concurrent.*;

public class Main {
    public static void main(String[] args) throws InterruptedException, CloneNotSupportedException {
       // System.out.println(Runtime.getRuntime().availableProcessors());
        MyThreadPool myThreadPool=new MyThreadPool(3);
//        for(int i=0;i<10;i++){
//            int taskId=i+1;
//            myThreadPool.setRun(()->{
//                System.out.println("任务id" + taskId + "," + Thread.currentThread().getName());
//            });
//        }

        //定制一个线程池
        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(3,5,1,
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(10));
        for (int i = 0; i < 10; i++) {
            int taskId=i+1;
            threadPoolExecutor.submit(()->{
                System.out.println("任务id" + taskId + "," + Thread.currentThread().getName());
            });
        }
    }
}
